package cn.grf.datasource.controller;

import cn.grf.datasource.pojo.User;
import cn.grf.datasource.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author grf
 * @apiNote
 * @since 2025/5/6
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @PostMapping
    public void insert(@RequestBody User user) {
        userService.insert(user);
    }

    @GetMapping("/list")
    public List<User> list() {
        return userService.list();
    }

    @GetMapping
    public User get(Long id) {
        return userService.get(id);
    }
}
